//
//  DetailSceneryTableViewCell.m
//  SoutheastAsia
//
//  Created by rimi on 16/1/15.
//  Copyright © 2016年 zlj. All rights reserved.
//

#import "DetailSceneryTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface DetailSceneryTableViewCell ()

@property (nonatomic, strong) UIImageView *headImageView;
@property (nonatomic, strong) UILabel *routeLabel;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *date;
@property (nonatomic, strong) NSString *days;

@end

@implementation DetailSceneryTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)loadNoteList:(NSDictionary *)noteList {
    NSURL *headImageUrl = [NSURL URLWithString:noteList[@"headImage"]];
    [self.headImageView sd_setImageWithURL:headImageUrl];
    [self.contentView addSubview:self.headImageView];
    
    self.title = noteList[@"title"];
    self.date = noteList[@"startTime"];
    
    NSNumber *number = noteList[@"routeDays"];
    self.days = [NSString stringWithFormat:@"天数:%@", number];
    
    [self setNeedsDisplay];
}

- (void)drawRect:(CGRect)rect {
    [self.title drawInRect:CGRectMake(CGRectGetMaxX(self.headImageView.frame) + 10, 15, 240, 60) withAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:18]}];
    [self.date drawInRect:CGRectMake(CGRectGetMaxX(self.headImageView.frame) + 10, 70, 120, 30) withAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16]}];
    [self.days drawInRect:CGRectMake(240, 70, 60, 30) withAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16]}];
}

- (UIImageView *)headImageView {
    if (!_headImageView) {
        _headImageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 10, 100, 80)];
    }
    return _headImageView;
}

@end
